<template>
	<view class="in_list">
		<navitop>
			<i class="iconfont icon-jiantou-copy" slot="left-slot" @click="outlot"></i>
			<span slot="center-slot">详情编辑</span>
			<!-- <i class="iconfont icon-youcecaidan" slot="right-slot"  @click="laert(data)"></i> -->
		</navitop>
		<div >
			<div :style="'margin-top:' + nv_height"></div>
			<scroll-view class="staff_b" scroll-y="true" touch-action=none; >
				<div class="public_list_out">
					<div >
						<div>
							<div class="public_list" v-for="(rows,ind) in rundataSorce.tal" v-if="rows.onEdit">
								<div class="public_list_left_one">
									<text style="color: red;" v-if="rows.onFill">*</text>{{rows.name}}: 
								</div>
								<div class="public_list_right" v-if="rows.type == '搜索选择'">
									<typeinput :type="rows.type" :values="vity_lists" :value="rundataSorce[rows.code]" :code="rows.code"  @user_alert="user_alert" ></typeinput>
								</div>
								<div class="public_list_right" v-else>
									<typeinput :type="rows.type" :values="rows.val" :value="rundataSorce[rows.code]" :code="rows.code"  @user_alert="user_alert" ></typeinput>
								</div>
							
							</div>
						</div>
					</div>
					<div class="list_tree">
						<setp :options="list" direction="column" :active="activety" @NuberList="NuberList"></setp>
					</div>
				</div>
				<div ></div><br>
				<div class="public_button" >
					<div class="public_text" @click="okclick">
						保&nbsp;&nbsp;存
					</div>
				</div><br><br>
			</scroll-view>
		</div>
	</view>
</template>
<script>
import typeinput from '@/pages/common/common/public_input/type_input'
import navitop from '@/components/common/navi-top'
import setp from '@/uni_modules/uni-steps/components/uni-steps/uni-steps'
import {listCompanyActivities,businesssave} from '@/common/api/job/jobapi.js'
export default {
	components: {
		setp,
		navitop,
		typeinput
	},
	props:{
		rundataSorce: {
			default: ''
		}
	},
	data(){
		return {
			list:[],
			activety: 0,
			window_height: '',
			vity_lists: '',
			nv_height:''
		}
	},
	mounted() {
		let arrYn = [];
		const res = uni.getSystemInfoSync();
		this.nv_height = uni.getSystemInfoSync().statusBarHeight + 55 + 'px';
		
		
		this.rundataSorce.tal.forEach(item => {
			if(item.code == 'saleStage'){
				for(let i in item.val.split(',')){
					arrYn.push({title: item.val.split(',')[i],index: i})
				}
			}
		})
		this.list = arrYn;
		
		this.list.forEach(item => {
			if(this.rundataSorce.saleStage == item.title){
				this.activety = Number(item.index)
			}
		})
		
		this.vity_list();
	},
	methods: {
		NuberList(val){
			this.activety = Number(val.index);
			this.rundataSorce.saleStage = val.title;
		},
		outlot(){
			this.$emit('close',2)
		},
		// 更新对象
		user_alert(val){
			let sun = this.rundataSorce.tal;
			for(let i in sun){
				if(sun[i].code == val.code){
					if(sun[i].dataType == 2){
						this.rundataSorce['defineFields'] =JSON.stringify({[sun[i].code]:val.value}) ;
					}
				}
			}
			if(val.id){
				this.rundataSorce[val.code] = val.value;
				this.rundataSorce['activityId'] = val.id;
			}else{
				this.rundataSorce[val.code] = val.value;
			}
		},
		// 活动列表
		vity_list(){
			listCompanyActivities().then((row) => {
				if(row.code == 200){
					this.vity_lists = row.data
				}
			})
		},
		okclick(){
			// delete this.rundataSorce.tal
			console.log(this.rundataSorce)
			if(this.rundataSorce){
				businesssave(this.rundataSorce).then((rows)=> {
					if(rows.code == 200){
						uni.showToast({
							title: '保存成功'
						});
						setTimeout(()=>{
							this.$emit('close',2)
						},1500)
					}
				})
			}
		}
		
	}
}	
	
	
</script>

<style scoped lang="scss">
.in_list {
	width: 100%;
	height: 100%;
	background-color: #fff;
	
	.staff_b {
		height: 800px;
	}
}

	.list_tree {
			width: 60%;
			padding: 30rpx 0 0 0;
		}
	
</style>
